﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace TinyCinema.UI.Pages.Promotion
{
    /// <summary>
    /// Interaction logic for Promotion.xaml
    /// </summary>
    public partial class Promotions : Page
    {
        public static DependencyProperty ContentFrameSourceProperty = DependencyProperty.Register("pagContentFrameSource", typeof(Page), typeof(Promotions));
        public Page pagContentFrameSource
        {
            get { return (Page)GetValue(ContentFrameSourceProperty); }
            set { SetValue(ContentFrameSourceProperty, value); }
        }
        public static Bussiness.Promotion.Promotions dataContext = new Bussiness.Promotion.Promotions();
        public StackPanel MainMenu { get; set; }
        public Promotions()
        {
            InitializeComponent();
            MainMenu = FindResource("MainMenu") as StackPanel;
            DataContext = dataContext;
            dataContext.SearchFilter.Add(App.Current.FindResource("langProName") as String);
            dataContext.SearchFilter.Add(App.Current.FindResource("langProID") as String);
        }
        static _Promotion.FormView pagFormView = new _Promotion.FormView();
        void MenuHandle(object sender, RoutedEventArgs e)
        {
            var btnSender = sender as Button;
            switch (btnSender.Uid)
            {
                case "Create": FormViewModeHandle();
                    (DataContext as Bussiness.Promotion.Promotions).CreateCommand.Execute(null);
                    break;
                case "Edit":
                    break;
                case "Delete":
                    break;
            }
        }
        public void FormViewModeHandle()
        {
            if (pagContentFrameSource is _Promotion.FormView) ViewModeHandle(btnPreViewMode, null);
            pagContentFrameSource = pagFormView;
        }
        _Promotion.GridView pagGridView = new _Promotion.GridView();
        Button btnPreViewMode;
        void ViewModeHandle(object sender, RoutedEventArgs e)
        {
            switch ((sender as Button).Uid)
            {
                case "GridView":
                    pagContentFrameSource = pagGridView;
                    break;
            }
            (sender as Button).IsEnabled = false;
            try
            {
                btnPreViewMode.IsEnabled = true;
            }
            catch { }
            btnPreViewMode = sender as Button;
        }

        private void ViewModeHandle(object sender, EventArgs e)
        {
            ViewModeHandle(sender, new RoutedEventArgs());
        }

        private void MainMenuInitialized(object sender, EventArgs e)
        {
            (sender as StackPanel).DataContext = dataContext;
        }
    }
}
